import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86187
 * Date: 2022-05-15
 * Time: 17:54
 */

//Scanner scan = new Scanner(System.in);

class Student implements Comparable<Student> {
    private int age;
    private String name;
    private double scores;

//    public int getAge() {
//        return age;
//    }
//
//    public void setAge(int age) {
//        this.age = age;
//    }
//
//    public String getName() {
//        return name;
//    }
//
//    public void setName(String name) {
//        this.name = name;
//    }
//
//    public double getScores() {
//        return scores;
//    }
//
//    public void setScores(double scores) {
//        this.scores = scores;
//    }

    public Student(int age, String name, double scores) {
        this.age = age;
        this.name = name;
        this.scores = scores;
    }

    @Override
    public String toString() {
        return "Student{" +
                "age=" + age +
                ", name='" + name + '\'' +
                ", scores=" + scores +
                '}';
    }

    @Override
    public int compareTo(Student o) {
        return this.age - o.age;   //从大到小排序，只能以年龄比较
    }
}

public class Test {

    public static void main(String[] args) {
        Student[] student = new Student[3];
        student[0] = new Student(15,"bit",76.4);
        student[1] = new Student(23,"asd",86.4);
        student[2] = new Student(18,"gb",68.4);
        System.out.println("排序前"+Arrays.toString(student));
        Arrays.sort(student);
        System.out.println("排序前"+Arrays.toString(student));

    }
}
